{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "!pip show pyecharts \n",
    "\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## pyecharts 可视化分析结果\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.insert(0, \".\")\n",
    "sys.path.insert(0, \"..\")\n",
    "\n",
    "import czsc\n",
    "print(czsc.__version__)\n",
    "\n",
    "from czsc.analyze import KlineAnalyze\n",
    "from pyecharts.charts import Tab\n",
    "from datetime import datetime\n",
    "\n",
    "# 如果需要实盘行情，导入聚宽数据\n",
    "# from czsc.data.jq import *\n",
    "\n",
    "# 导入 tushare 数据\n",
    "from czsc.data.ts import *\n",
    "\n",
    "from plot import *\n",
    "from czsc.utils import ka_to_echarts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "end_date=datetime.strptime(\"20200913\", \"%Y%m%d\")\n",
    "\n",
    "k1m = get_kline(\"300803.SZ-E\", end_date=end_date, freq='1min', count=2000)\n",
    "k5m = get_kline(\"300803.SZ-E\", end_date=end_date, freq='5min', count=2000)\n",
    "k30m = get_kline(\"300803.SZ-E\", end_date=end_date, freq='30min', count=2000)\n",
    "k_d = get_kline(\"300803.SZ-E\", end_date=end_date, freq='D', count=2000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "ka_1m = KlineAnalyze(k1m, name=\"1分钟\", bi_mode=\"new\", max_xd_len=20, ma_params=(5, 34, 120), verbose=False)\n",
    "ka_5m = KlineAnalyze(k5m, name=\"5分钟\", bi_mode=\"new\", max_xd_len=20, ma_params=(5, 34, 120), verbose=False)\n",
    "ka_30m = KlineAnalyze(k30m, name=\"30分钟\", bi_mode=\"new\", max_xd_len=20, ma_params=(5, 34, 120), verbose=False)\n",
    "ka_d = KlineAnalyze(k_d, name=\"日线\", bi_mode=\"new\", max_xd_len=20, ma_params=(5, 34, 120), verbose=False)\n",
    "\n",
    "width = \"950px\"\n",
    "height = \"480px\"\n",
    "chart_1m = ka_to_echarts(ka_1m, width, height)\n",
    "chart_5m = ka_to_echarts(ka_5m, width, height)\n",
    "chart_30m = ka_to_echarts(ka_30m, width, height)\n",
    "chart_d = ka_to_echarts(ka_d, width, height)\n",
    "\n",
    "tab = Tab()\n",
    "tab.add(chart_1m, \"1分钟\")\n",
    "tab.add(chart_5m, \"5分钟\")\n",
    "tab.add(chart_30m, \"30分钟\")\n",
    "tab.add(chart_d, \"日线\")\n",
    "tab.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
